<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>给组件绑定原生事件</title>
  <script src="../asset/js/vue.js"></script>
</head>

<body>
  <div id="root">
    <!-- 使用修饰符，给组件绑定原生事件 -->
    <child @click.native='handleClick'></child>
  </div>
  <script>
    Vue.component('child', {
      template: '<div>Child</div>',
      /* template: '<div @click="handleChildClick">Child</div>',
      methods: {
        handleChildClick() {
          console.log('child click')
          this.$emit('click') //向外触发自定义事件
        }
      } */
    })
    let vm = new Vue({
      el: '#root',
      methods: {
        /* 没法被执行，因为handleClick是自定义事件 */
        handleClick() {
          console.log('click')
        }
      }
    })
  </script>
</body>

</html>